<?php
/**********************************************************************************
 
 	Class that provides functions to display pages.
	
	Copyright (C) 2010 Benjamin Thomas
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 	Author: Benjamin Thomas
	Email: thomas.ben@gmail.com
 	Created: 06.19.10
 	Revised: 07.04.10
 
 	Calls: 
 
 ***********************************************************************************
 */
require_once(dirname(__FILE__) . '/Table.php');
/*
	Returns copper values from BeanCounter into XXgXXsXXc.
	Rounds decimals down (1001.2 = 10 silver, 1 copper)
*/
function getGold($val) {
	$neg = false;
	if ($val < 0) { 
		$val = abs($val);
		$neg = true;
	}
	$val = floor($val);
	$result = "";
	$g = floor($val / 10000);
	$s = floor(($val - ($g * 10000)) / 100);
	$c = floor(($val - ($g * 10000) - ($s * 100)));
	$result = $c . '<img src="images/copper.png" /> ';
	if ($s || $g) { $result = $s . '<img src="images/silver.png" /> ' . $result; }
	if ($g) { $result = number_format($g) . '<img src="images/gold.png" /> ' . $result; }
	if ($neg) {
		$result = '-' . $result;
	}
	return $result;
}

function getGoldArr($val) {
	$g = number_format(floor($val / 10000));
	$s = floor(($val - ($g * 10000)) / 100);
	$c = floor(($val - ($g * 10000) - ($s * 100)));
	return array($g,$s,$c);
}

function getGoldOnly($val) {
	return number_format(floor($val / 10000)) . '<img src="images/gold.png" /> ';
}

function getGoldInt($val) {
	return ($val / 10000);
}

function printPager() {
	echo '<div id="pager" class="pager" style="text-align:right; magin-top: 10px; margin-bottom: -15px;">';
	echo '<form>';
	echo '	<img src="images/first.png" class="first"/> ';
	echo '	<img src="images/prev.png" class="prev"/>';
	echo '	<span style="color: black" class="pagedisplay"></span>';
	echo '	<img src="images/next.png" class="next"/> ';
	echo '	<img src="images/last.png" class="last"/> ';
	echo '	<select class="pagesize"> ';
	echo '		<option  value="10">10</option> ';
	echo '		<option selected="selected"  value="20">20</option> ';
	echo '		<option value="30">30</option> ';
	echo '		<option  value="40">40</option> ';
	echo '</select> ';
	echo '</form> ';
	echo '</div>';
}

function printn($str) {
	print($str . "\n");
}

function mydump($arr) {
	echo "<pre>"; echo  print_r($arr); echo "</pre>";
}

?>